/* 
 * v-preventReClick：按钮事件间隔点击时间控制
 * Created by Penglei
 * On 2023/02/22
 */
// 按钮事件间隔点击时间（ms）
const btnClickTime = 1500;

export default {
	mounted(el, binding, vnode) {
		const { value } = binding;
		let timer;
		el.addEventListener('click', (e) => {
			if (!el.disabled) {
				el.disabled = true;
				if (timer) {
					clearTimeout(timer);
				}
				timer = setTimeout(() => {
					el.disabled = false;
				}, value || btnClickTime)
			}
		})
	}
}

